<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>屏幕锁定页面</title>
		<script src="js/global.js"></script>
		<!--<script src="js/easyUIvalidate.js"></script>-->
		
			<style type="text/css">
			html {
				width: 100%;
				height: 100%;
			}
			h4{
				display: inline;
			}
			body {
				background-repeat: no-repeat;
				background-position: center center #2D0F0F;
				background-color: #00BDDC;
				background-image: url(img/zt1.jpg);
				background-size: 100% 100%;
			}
			
			.snow-container {
				position: fixed;
				top: 100px;
				left: 0;
				width: 100%;
				height: 100%;
				pointer-events: none;
				z-index: 100001;
			}
		</style>
		
	</head>
	<body>
		<div align="center" style="padding: 150px; width: 1250px; height: 351px;">
			<div style="background-color: #D7EBF9;width: 400px;height: 300px; ">
				<h1 style="color: #31B0D5;">BEST-知客招生系统</h1>
				<form class="layui-form" style="width: 400px; height: 200px;">
				<table style="height: 200px;">
					<tbody>
						<tr>
							<td>用户名：<h4 id="user_name"></h4></td>
						</tr>
						<tr>
							<td>状态：<span class="locked" style="color: red;">您的账号锁定中...</span></td>
						</tr>
						<tr>
							<td> <input type="password" placeholder="请输入密码" lay-verify="required" name="password" id="password" class="layui-input">
                       		</td>
                            <td>
                            <button class="layui-btn" lay-submit lay-filter="formDemo">进入系统</button>
							</td>
						</tr>
						
						<tr>
							<td><button class="layui-btn layui-btn-normal"><a href="time1.html">时间天气</a></button></td>
							<td><button class="layui-btn"><a href="login.html">切换账号</a></button></td>
						</tr>
					</tbody>
				</table>
			</form>
			</div>
			
		</div>
		
		<script>
			//Demo
			layui.use('form', function() {
				var form = layui.form;

			$(function(){
					$("#user_name").text(globalData.getCurUName());
				})

				//监听提交
				form.on('submit(formDemo)', function(data) {
					
					//layer.msg(JSON.stringify(data.field));
					console.log(data.field);
					$.post(globalData.server + "login?loginName="+globalData.getCurUName(), data.field, function(res) {
						//loginName = $("#user_name").text(globalData.getCurUName());
						console.log(res);
						if(res != null && res.code==0) {//登录成功
							//保存token
							globalData.setToken(res.token)
							//保存登录成功的用户信息
							globalData.setUserInfo(res.data.id,res.data.loginName)
							console.log(globalData.getToken());
							//跳转到index页面
							window.location.href = "index.html";
						}else if(res.code==502){
							layer.msg(res.msg,{
								icon: 7,
								time:3000
							});
						}else if(res.code==503){
							layer.msg(res.msg,{
								icon: 4,
								time:3000
							});
						}else if(res.code==504){
							layer.msg(res.msg,{
								icon: 4,
								time:3000
							});
						}else{
							layer.msg("登录失败，用户名不存在",{
								icon: 7,
								time:2000
							});
						}
					})

					//不提交表单
					return false;
				});
			});
		</script>
		
	
	
	</body>
</html>
